home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Telnet 2.6.1d1 4⁄26⁄94 Folder / source / network / netevent.c < prev    next >
Text File  |  1994-03-21  |  18KB  |  628 lines

  1. /*
  2. *    netevent.c
  3. *     Originally by Gaige B. Paulsen
  4. *****************************************************************
  5. *    NCSA Telnet for the Macintosh                                *
  6. *                                                                *
  7. *    National Center for Supercomputing Applications                *
  8. *    Software Development Group                                    *
  9. *    152 Computing Applications Building                            *
  10. *    605 E. Springfield Ave.                                        *
  11. *    Champaign, IL  61820                                        *
  12. *                                                                *
  13. *    Copyright (c) 1986-1993,                                    *
  14. *    Board of Trustees of the University of Illinois                *
  15. *****************************************************************
  16. *    Network event handler for NCSA Telnet for the Macintosh
  17. *
  18. *    Called by:
  19. *        event.c
  20. *        maclook.c
  21. *
  22. *    Revisions:
  23. *    7/92    Telnet 2.6:  added the 2 global structures, and cleaned up defines -- Scott Bulmahn
  24. */
  25.  
  26. #ifdef MPW
  27. #pragma segment Network
  28. #endif
  29.  
  30. #include <stdio.h>
  31. #include <string.h>
  32.  
  33. #include "TelnetHeader.h"
  34.  
  35. #include "netevent.proto.h"
  36. #include "InternalEvents.h"
  37. #include "wind.h"
  38. #include "mydnr.proto.h"
  39. #include "bkgr.proto.h"
  40. #include "maclook.proto.h"
  41. #include "network.proto.h"
  42. #include "menuseg.proto.h"
  43. #include "rsmac.proto.h"
  44. #include "vrrgmac.proto.h"
  45. #include "tekrgmac.proto.h"
  46. #include "vsdata.h"
  47. #include "vskeys.h"
  48. #include "translate.proto.h"
  49. #include "debug.h"
  50. #include "parse.proto.h"
  51. #include "ftpbin.proto.h"
  52. #include "Connections.proto.h"
  53. #include "event.proto.h"
  54.  
  55. #include "telneterrors.h"
  56.  
  57. extern WindRec
  58.     *screens;                    /* The screen array from Maclook */
  59. extern char *tempspot;            /* 256 bytes for temp strings */
  60. extern short scrn;
  61. extern MenuHandle myMenus[];
  62.  
  63. short
  64.     FileInTransit,
  65.     blocksize,                    /*    how large do we make the blocks when we read? */
  66.     gQueueError = 0,            //    Set to 1 if the queue fills up.
  67.     gQueueLength = 0,            //    Used to monitor queue length for debugging purposes.
  68.     gQueueInUse = 0;            //        Ditto.
  69.     
  70. QHdr    gEventsQueue, gEventsFreeQueue;
  71.         
  72. unsigned char *readspace;        /* main buffer space */
  73.  
  74. static void RangeError(short i);
  75. void    ftppasteText(short scrn);
  76.  
  77. #define PFTP 1
  78. #define PRCP 2
  79. #define PDATA 3
  80.  
  81. //    Our "give time" routine
  82. void Stask( void)
  83. {
  84. }
  85.  
  86. //    Every time we open or close a network connection, we add or remove a few elements
  87. //    to/from the queue to assure that there will always be some free elements laying
  88. //    around.  This allows us to avoid Dequeue'ing at interrupt time, which causes 
  89. //    nasty mutex problems since we walk the queue in netgetevent at non-interrupt time.
  90. void    ChangeQueueLength(short delta)
  91. {
  92.     internal_event    *theEvent;
  93.     
  94.     if (delta > 0)
  95.         while (delta != 0) {
  96.             theEvent = (internal_event *) NewPtrClear(sizeof(internal_event));
  97.             Enqueue((QElemPtr)theEvent, &gEventsFreeQueue);
  98.             gQueueLength++;
  99.             delta--;
  100.             }
  101.     else
  102.         while (delta != 0) {
  103.             theEvent = (internal_event *)gEventsFreeQueue.qHead;
  104.             Dequeue((QElemPtr)theEvent, &gEventsFreeQueue);
  105.             if (theEvent) DisposePtr((Ptr)theEvent);
  106.             gQueueLength--;
  107.             delta++;
  108.             }
  109. }
  110.             
  111. /***********************************************************************/
  112. /*  netgetevent
  113. *   Retrieves the next event (and clears it) which matches bits in
  114. *   the given mask.  Returns the event number or -1 on no event present.
  115. *   Also returns the exact class and the associated integer in reference
  116. *   parameters.
  117. */
  118.  
  119. short netgetevent(
  120. //    short    mask,
  121.     short    *class,
  122.     short    *data1,
  123.     long    *data2
  124.   )
  125. {
  126.     internal_event    *theEvent;
  127.     short            event;
  128. //#define    QUEUE_STATS
  129. #ifdef    QUEUE_STATS
  130.     char            qs[255];
  131.     static    long    timer = 0;
  132.     
  133.     if (TickCount() - timer > 60*30) {
  134.         sprintf(qs, "QueueLength: %d, InUse: %d", gQueueLength, gQueueInUse);
  135.         timer = TickCount();
  136.         putln(qs);
  137.         }
  138. #endif    QUEUE_STATS
  139.  
  140.     if (gQueueError)                // Yikes, we actually ran out of queue elements!
  141.         DebugStr("\pOut of Queue Elements, please quit as quickly as possible!");
  142.         
  143.     // Spin until we hit the end of the queue or if we Dequeue an element that is not
  144.     // already dequeued.  If we don't do this check on Dequeue, someone else could come
  145.     // in and dequeue an element that we are about to dequeue.  Thus, WHAM! we both have
  146.     // that queue element.
  147.     while ((theEvent = (internal_event *)gEventsQueue.qHead) != NULL) {
  148.         if (Dequeue((QElemPtr)theEvent, &gEventsQueue) == noErr)
  149.             break;
  150.         }
  151.         
  152. //    while ((theEvent != NULL) && !(theEvent->eclass & mask))
  153. //        theEvent = (internal_event *)theEvent->qLink;
  154.     
  155.     if (theEvent == NULL) return(-1);
  156.         
  157. //    (void) Dequeue((QElemPtr)theEvent, &gEventsQueue);
  158.  
  159.     *class = theEvent->eclass;
  160.     *data1 = theEvent->data1;
  161.     *data2 = theEvent->data2;
  162.     event = theEvent->event;
  163.     
  164.     Enqueue((QElemPtr)theEvent, &gEventsFreeQueue);
  165.     gQueueInUse--;
  166.     return(event);
  167. }
  168.  
  169. /***********************************************************************/
  170. /*  netputevent
  171. *   add an event to the queue.
  172. *   Will probably get the memory for the entry from the free list.
  173. *   Returns 0 if there was room, 1 if an event was lost.
  174. */
  175. short netputevent
  176.   (
  177.     short    class,
  178.     short    what,
  179.     short    data1,
  180.     long    data2
  181.   )
  182. {
  183.     internal_event    *theEvent;
  184.     
  185.     while ((theEvent = (internal_event *)gEventsFreeQueue.qHead) != NULL) {
  186.         if (Dequeue((QElemPtr)theEvent, &gEventsFreeQueue) == noErr)
  187.             break;
  188.         }
  189.             
  190.     if (theEvent == NULL) {
  191.         gQueueError = 1;                    // Darn, we filled the queue, alert the user.
  192.         return(-1);
  193.         }
  194.     else
  195.         gQueueInUse++;
  196.         
  197.     theEvent->qType = 0;    
  198.     theEvent->eclass = class;
  199.     theEvent->event = what;
  200.     theEvent->data1 = data1;
  201.     theEvent->data2 = data2;
  202.     
  203.     Enqueue((QElemPtr)theEvent, &gEventsQueue);
  204.     return(0);
  205. }
  206.  
  207. /***************************************************************************/
  208. /*  netputuev
  209. *   put a unique event into the queue
  210. *   First searches the queue for like events
  211. */
  212. short netputuev
  213.   (
  214.     short    class,
  215.     short    what,
  216.     short    data1,
  217.     long    data2
  218.   )
  219. {
  220.     internal_event    *theEvent = (internal_event *)gEventsQueue.qHead;
  221.     
  222.     while((theEvent != NULL) && ((theEvent->eclass != class) || (theEvent->event != what)
  223.             || (theEvent->data1 != data1) || (theEvent->data2 != data2)))
  224.                 theEvent = (internal_event *)theEvent->qLink;
  225.                 
  226.     if (theEvent != NULL) return(0);
  227.     
  228.     return(netputevent(class, what, data1, data2));
  229. }
  230.  
  231. void RangeError(short i)
  232. {
  233.     char temp[20];
  234.  
  235.     sprintf(temp,"%d in %d", -i,TelInfo->numwindows);
  236.     putln(temp);
  237. }
  238.  
  239. short    WindByPort(short port)
  240. {
  241.     short i=0;
  242.  
  243.     while (i<TelInfo->numwindows &&
  244.             (screens[i].port != port || 
  245.                 ((screens[i].active != CNXN_ACTIVE) && (screens[i].active != CNXN_OPENING)))
  246.             ) i++;
  247.  
  248.     if (i>=TelInfo->numwindows) {
  249.         i = 0;
  250.         while ((i<TelInfo->numwindows) &&
  251.                 ((screens[i].ftpport != port) ||
  252.                     ((screens[i].active != CNXN_ACTIVE) && (screens[i].active != CNXN_OPENING)))
  253.                 ) i++;
  254.         if (i>=TelInfo->numwindows) {                    /* BYU */
  255.             putln("Can't find a window for the port # in WindByPort");    /* BYU */
  256.             RangeError(i);            /* BYU */
  257.             if (i==0) i=999;        /* BYU */
  258.             return(-i);                /* BYU */
  259.             }                        /* BYU */
  260.         }                            /* BYU */
  261.  
  262.     return(i);
  263. }
  264.  
  265. void FlushNetwork(short scrn)
  266. {
  267.     short throwsize,cnt=512;
  268.     
  269.     if (blocksize < 512)
  270.         throwsize = 512;
  271.     else
  272.         throwsize = blocksize;
  273.  
  274.     RSskip(screens[scrn].vs, 1);                /* Don't do any output */
  275.  
  276.     while (cnt>0) {
  277.         cnt = netread(screens[scrn].port,readspace,throwsize);
  278.         parse( &screens[scrn ], readspace, cnt);
  279.         }
  280.  
  281.     RSskip(screens[scrn].vs, 0);                /* Do output now */
  282.     SetPort( screens[scrn].wind);
  283.     InvalRect(&screens[scrn].wind->portRect);    /* Don't forget to redraw */
  284. }
  285.  
  286. void    ftppasteText(short scrn)        /* BYU */
  287. {                        /* BYU */
  288.     char *ascii;        /* BYU */
  289.                         /* BYU */
  290.     ascii = screens[scrn].outptr;                    /* BYU */
  291.     while ((screens[scrn].outlen > 0) &&             /* BYU */
  292.         (*ascii>31) && (*ascii <127)) {                /* BYU */
  293.         parse( &screens[ scrn],(unsigned char *) ascii, 1);        /* BYU LSC */
  294.         screens[scrn].kbbuf[ screens[scrn].kblen++ ] = *ascii;    /* BYU */
  295.         screens[scrn].outlen--;                        /* BYU */
  296.         ascii++;                                    /* BYU */
  297.         }                                            /* BYU */
  298.     screens[scrn].outptr = ascii;                    /* BYU */
  299.     if (*ascii == '\015') {                            /* BYU */
  300.         parse( &screens[scrn],(unsigned char *) "\015\012",2);    /* BYU LSC */
  301.         screens[scrn].kbbuf[ screens[scrn].kblen++ ] = 0;        /* BYU */
  302.         ftppi(screens[scrn].kbbuf);                                /* BYU - ftp client */
  303.         screens[scrn].kblen=0;                                    /* BYU */
  304.         }                                    /* BYU */
  305.     while ((screens[scrn].outlen > 0) &&     /* BYU */
  306.         ((*ascii<=31) || (*ascii >=127))) {    /* BYU */
  307.         screens[scrn].outlen--;                /* BYU */
  308.         screens[scrn].outptr++;                /* BYU */
  309.         }                /* BYU */
  310. }                        /* BYU */
  311.  
  312. void pasteText(short scrn)
  313. {
  314.     short amount;
  315.     if (!screens[scrn].outlen)
  316.         return;
  317.  
  318.  
  319.     if (netpush(screens[scrn].port) != 0) {            /* BYU 2.4.16 - wait until not busy */
  320.         netputevent( USERCLASS, PASTELEFT, scrn,0);    /* BYU 2.4.16 */
  321.         return;                                        /* BYU 2.4.16 */
  322.     }                                                /* BYU 2.4.16 */
  323.     if (screens[scrn].incount) {                    /* BYU 2.4.16 */
  324.         screens[scrn].incount = 0;                    /* BYU 2.4.16 */
  325.         screens[scrn].outcount = 0;                    /* BYU 2.4.16 */
  326.         netputevent( USERCLASS, PASTELEFT, scrn,0);    /* BYU 2.4.16 */
  327.         return;                                        /* BYU 2.4.16 */
  328.     }                                                /* BYU 2.4.16 */
  329.     if (screens[scrn].outcount < 2) {                /* BYU 2.4.16 */
  330.         screens[scrn].outcount++;                    /* BYU 2.4.16 */
  331.         netputevent( USERCLASS, PASTELEFT, scrn,0);    /* BYU 2.4.16 */
  332.         return;                                        /* BYU 2.4.16 */
  333.     }
  334.     if (netqlen(screens[scrn].port) > 0) {            /* BYU 2.4.16 - wait until not full */
  335.         netputevent( USERCLASS, PASTELEFT, scrn,0);    /* BYU 2.4.16 */
  336.         return;                                        /* BYU 2.4.16 */
  337.     }                                                /* BYU 2.4.16 */
  338.  
  339.     if (screens[scrn].ftpstate != 0)                 /* BYU */
  340.         ftppasteText( scrn);                        /* BYU */
  341.     else {                                            /* BYU */
  342.         if (!screens[scrn].pastemethod) {    // Do this all at once?
  343.             amount = netwrite(screens[scrn].port, screens[scrn].outptr,
  344.                                 screens[scrn].outlen);
  345.             }
  346.         else {        // Nope, do it in blocks
  347.             if (screens[scrn].pastesize <= screens[scrn].outlen)
  348.                 amount = screens[scrn].pastesize;
  349.             else
  350.                 amount = screens[scrn].outlen;
  351.             amount = netwrite(screens[scrn].port, screens[scrn].outptr, amount);
  352.             }
  353.             
  354.         if (screens[scrn].echo)                                        /* BYU */
  355.             parse( &screens[scrn],(unsigned char *) screens[scrn].outptr,amount);    /* BYU LSC */
  356.         screens[scrn].outlen -= amount;                                /* BYU */
  357.         screens[scrn].outptr += (long) amount;                        /* BYU */
  358. /*        screens[scrn].outcount += amount;            /* BYU LSC */
  359.         }                                                            /* BYU */
  360.  
  361.     if ( screens[scrn].outlen <=0) {
  362.         screens[scrn].clientflags &= ~PASTE_IN_PROGRESS;    /* BYU LSC */
  363.         HUnlock(screens[scrn].outhand);
  364.         DisposHandle(screens[scrn].outhand);
  365.         screens[scrn].outptr = (char *) 0L;            /* BYU LSC */
  366.         screens[scrn].outhand = (char **) 0L;        /* BYU LSC */
  367.         }
  368.     else
  369.         netputevent( USERCLASS, PASTELEFT, scrn,0);
  370. }
  371.  
  372. void DoNetEvents(void)
  373. {
  374.     short        i, cnt;
  375.     long    ftptime = 0;
  376.     short    event, class, data1;
  377.     long    data2, pos;
  378.     
  379.     if ((event = netgetevent(&class, &data1, &data2)) < 0) return;
  380.  
  381.     if ( (TickCount() - ftptime > 60*2) && FileInTransit) {
  382.         ftptime = TickCount();
  383.         Sftpstat(&pos);                    /* get transfer status */
  384.         if (pos <= 0) 
  385.             ftpmess("FTP Status: transferring\015\012");
  386.         else 
  387.             {
  388.             if (FileInTransit+2)
  389.                 sprintf((char *) tempspot,"FTP Status: %ld bytes remaining.\015\012", pos);        /* BYU LSC */
  390.             else
  391.                 sprintf((char *) tempspot,"FTP Status: %ld bytes transferred.\015\012", pos);    /* BYU LSC */
  392.  
  393.             ftpmess((char *) tempspot);    /* BYU LSC */
  394.             }
  395.         }
  396.         
  397.     switch(class) {
  398.         case SCLASS:
  399.             switch (event) {
  400.                 case FTPACT:
  401.                     ftpd(0, data1);
  402.                     break;
  403.                 case CLOSEDONE:                    /* Used in the drivers */
  404.                     netclose(data1);
  405.                     break;
  406.                 case CLOSEDONE+1:                /* Used in the drivers */
  407.                     netclose(data1);
  408.                     break;
  409.                 default:
  410.                     break;
  411.             }
  412.             break;
  413.             
  414.         case CONCLASS:                            /* Connection type event */
  415.             switch(GetPortType(data1)) {
  416.                 case PFTP:
  417.                     rftpd(event,data1);        /* BYU 2.4.16 */
  418.                     break;
  419.                 case PDATA:
  420.                     ftpd(event,data1);
  421.                     break;
  422.                 case UDATA:                        /* BYU */
  423.                     userftpd(event,data1);        /* BYU */
  424.                     break;                        /* BYU */
  425.                 default:
  426.                 case CNXN_TYPE:
  427.                     switch (event) {
  428.                         case CONOPEN:                /* connection opened or closed */
  429.                             i=WindByPort(data1);
  430.                             if (i<0) { 
  431.                                 RangeError(i); 
  432.                                 return;
  433.                                 }
  434.                                  
  435.         /* BYU mod - This tests TRUE if it is the telnet port or the main ftp port */
  436.                             if (data1 == screens[i].port) {        /* BYU - is this Telnet? */
  437.                                 screens[ i].active= CNXN_ACTIVE;
  438.                                 RSshow( screens[i].vs);            /* BYU */
  439.                                 SelectWindow(screens[i].wind);    /* BYU */
  440.                                 /*
  441.                                  * Send Kerberos initial options.
  442.                                  */
  443.                                 send_auth_opt(&screens[i]);
  444.         #if 0                                                    /* BYU 2.4.20 */
  445.                                 if (screens[i].ftpstate != 0)     /* BYU 2.4.20 - Only if not FTP */
  446.                                     userftpd(CONOPEN,data1);        /* BYU */
  447.         #else                                                    /* BYU 2.4.20 */
  448.                                 if (screens[i].ftpstate == 0) {    /* BYU - Only if not FTP */
  449.                                     netpush(screens[i].port);    /* BYU */
  450.                                     netwrite(screens[i].port,"\377\375\001\377\375\003\377\374\43",9); /* BYU - Default telnet parms */
  451.                                     // IAC DOTEL ECHO IAC DOTEL SGA IAC WONTTEL XDISPLOC
  452.                                 } else {                        /* BYU */
  453.                                     userftpd(CONOPEN,data1);        /* BYU */
  454.                                 }                                /* BYU */
  455.         #endif                                                    /* BYU 2.4.20 */
  456.                                 screens[i].Usga=1;        /* BYU */
  457.                                 screens[i].echo = 1;
  458.                                 changeport(scrn,i);        /* BYU */
  459.                                 SetMenuMarkToLiveForAGivenScreen(scrn);            /* BYU */
  460.                                 DoTheMenuChecks();        /* BYU */
  461.                             } else {                    /* BYU - not Telnet so must be FTP */
  462.                               userftpd(CONOPEN,data1);    /* BYU */
  463.                             }                            /* BYU */
  464.                             break;
  465.          
  466.                         case CONDATA:                /* data arrived for me */
  467.                             i=WindByPort(data1);                                    /* BYU */
  468.                             if (i<0) { RangeError(i); return; }                    /* BYU */
  469.                             if (TelInfo->ScrlLock || !screens[i].enabled)    /* BYU LSC */
  470.                                 netputuev( CONCLASS, CONDATA, data1,0);
  471.                             else {
  472.                                 if (screens[i].ftpstate == 0) 
  473.                                     {                    /* normal session connection */    
  474.                                     cnt = netread(data1,readspace,blocksize);    /* BYU LSC */
  475.                                     parse( &screens[i], readspace, cnt);    /* BYU LSC */
  476.                                     screens[i].incount += cnt;                /* BYU LSC */
  477.                                     }                            /* BYU */
  478.                                 else {                            /* BYU */
  479.                                     userftpd(CONDATA,data1);        /* BYU */
  480.                                     }                            /* BYU */
  481.                                 }
  482.                             break;
  483.         
  484.                         case CONFAIL:
  485.                             {
  486.                                 short    i;
  487.                                 Str255    scratchPstring;
  488.                                 
  489.                                 netclose( data1);
  490.                                 i= WindByPort(data1);
  491.                                 if (i<0) { RangeError(i); return; }
  492.                                 BlockMove((Ptr)screens[i].machine, (Ptr)scratchPstring, Length(screens[i].machine)+1);
  493.                                 PtoCstr(scratchPstring);
  494.                                 DoError(807 | NET_ERRORCLASS, LEVEL2, (char *)scratchPstring);
  495.                                 
  496.                                 if (screens[i].active != CNXN_ACTIVE) destroyport(i);    // JMB - 2.6
  497.                                 else removeport( i);        // JMB - 2.6
  498.                             }
  499.                             break;
  500.         
  501.                         case CONCLOSE:
  502.                             {
  503.                                 short i;
  504.         
  505.                                 i= WindByPort(data1);
  506.                                 if (i<0) { 
  507.                                     netclose( data1);            /* We close again.... */
  508.                                     RangeError(i);
  509.                                     return;
  510.                                     }
  511.         /* BYU - This tests TRUE if it is the telnet port or the main ftp port */
  512.                                 if (data1 == screens[i].port) {        /* BYU */
  513.                                     putln("Closing....");            /* BYU */
  514.                                     FlushNetwork(i);                /* BYU */
  515.                                     netclose( screens[i].port);        /* BYU */
  516.                                     removeport(i);                    /* BYU */
  517.                                     }                                /* BYU */
  518.                                 else {                                /* BYU */
  519.                                     userftpd(CONCLOSE,data1);            /* BYU */
  520.                                     }                                /* BYU */
  521.                             }
  522.                             break;
  523.         
  524.                         default:
  525.                             break;
  526.                         }
  527.                     break;    /* Case port type = CNXN_TYPE */
  528. //                default:
  529. //                    putln("Received CONCLASS event for port w/o valid type.");
  530. //                    break;
  531.                 }
  532.             break;    /* CONCLASS */
  533.  
  534.     case USERCLASS:
  535.             switch (event) {
  536.                 case DOMAIN_DONE:    // data1 = screen #, data2 = ptr to info structure
  537.                     HandleDomainDoneMessage(data1, data2);
  538.                     break;
  539.                 case FTPBEGIN:
  540.                     FileInTransit=data1;
  541.                     ftptime=TickCount();
  542.                     break;
  543.                 case FTPEND:
  544.                     ftpmess("FTP Transfer Concluding\015\012");
  545.                     ftpmess("\015\012");
  546.                     FileInTransit=0;
  547.                     break;
  548.                 case FTPCOPEN:
  549.                     {
  550.                         ip_addrbytes    ftpinfo;
  551.                         
  552.                         Str255    remoteMachineName;
  553.                         
  554.                         if (gFTPServerPrefs->ResetMacBinary) 
  555.                             TelInfo->MacBinary = gFTPServerPrefs->UseMacBinaryII;
  556.                         updateMenuChecks();
  557.                         TelInfo->xferon=1;
  558.                         updateCursor(1);
  559.                         ftpmess("-----------------------------------------------------------------------------\015\012");
  560.                         ftpmess("FTP server initiated from host: ");
  561.                         ftpinfo.a.addr = Sftphost();
  562.                         
  563.                         if (!TranslateIPtoDNSname(ftpinfo.a.addr, remoteMachineName)) 
  564.                             sprintf((char *) &tempspot[4],"%u.%u.%u.%u\015\012",
  565.                                     (unsigned char)ftpinfo.a.byte[0],
  566.                                     (unsigned char)ftpinfo.a.byte[1],
  567.                                     (unsigned char)ftpinfo.a.byte[2],
  568.                                     (unsigned char)ftpinfo.a.byte[3]);
  569.                         else {
  570.                             PtoCstr(remoteMachineName);
  571.                             sprintf((char *) &tempspot[4],"%s\015\012",remoteMachineName);
  572.                             }
  573.                         ftpmess((char *) &tempspot[4]);        /* BYU LSC */
  574.                     }
  575.                     break;
  576.                 case FTPCLOSE:
  577.                     TelInfo->xferon=0;
  578.                     updateCursor(1);
  579.                     if (gFTPServerPrefs->ResetMacBinary) 
  580.                         TelInfo->MacBinary = gFTPServerPrefs->UseMacBinaryII;
  581.                     updateMenuChecks();
  582.                     ftpmess("FTP server ending session\015\012");
  583.                     ftpmess("-----------------------------------------------------------------------------\015\012");
  584.                     ftpmess("\015\012");
  585.  
  586.                     break;
  587.                 case RG_REDRAW:            /* RGredraw event */
  588.                     if (VGalive(data1) && RGsupdate(data1))
  589.                         TekEnable(data1);
  590.                     break;
  591.                 case PASTELEFT:
  592.                     pasteText(data1);
  593.                     break;
  594.                 default:
  595.                     break;
  596.             }
  597.             break;    /* USERCLASS */
  598.  
  599.     default:
  600.         break;
  601.     } /* switch (CLASS) */
  602.     
  603. } /* DoNetEvents */
  604.         
  605. /*    setblocksize()
  606.         Make sure that we have space for the block of data that is to be read each
  607.         time the netread() is called. */
  608. short setblocksize(short tosize)
  609. {
  610.     blocksize = tosize;                            /* keep size of block */
  611.     
  612.     if (tosize < 512)                            /* minimum buffer */
  613.         tosize = 512;
  614.  
  615.     if (readspace)
  616.         DisposPtr((Ptr)readspace);                        /* free old block */
  617.         
  618.     if (NULL == (readspace = (unsigned char *) NewPtrClear(tosize + 100)))    /* BYU LSC */
  619.         return(-1);
  620.  
  621.     return(0);
  622. }
  623.  
  624.  
  625.  
  626.  
  627.  
  628.